package zhieasy.cn.service.found.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import zhieasy.cn.common.utils.ResultVOUtil;
import zhieasy.cn.common.vo.ResultVO;
import zhieasy.cn.model.found.Notice;
import zhieasy.cn.persistence.mapper.found.NoticeMapper;
import zhieasy.cn.service.found.NoticeService;


/**
 * @author wangzeya
 * @create 2020-08-02 15:53
 */
@Service

public class NoticeServiceImpl implements NoticeService {

    @Autowired
    private NoticeMapper noticeMapper;

    /**
     * 发布公告
     * @param notice
     */
    @Override
    public ResultVO createNotice(Notice notice) {
        noticeMapper.insert(notice);
        return ResultVOUtil.success();
    }

    /**
     * 查询公告列表
     * @return
     */
    @Override
    public ResultVO<IPage<Notice>> findNoticeList(int pageNum, int pageSize) {
        IPage<Notice> noticePage = new Page<>(pageNum, pageSize);//参数一是当前页，参数二是每页个数
        IPage<Notice> noticeIPage = noticeMapper.selectPage(noticePage, null);
        return ResultVOUtil.success(noticeIPage);

    }
}
